package cn.hftoday.db;

/**
 * Database connection
 * @author lane.cn@gmail.com
 *
 */
public interface DatabaseConnection {
	/**
	 * db connection name
	 * @param name
	 */
	void setName(String name);
	
	/**
	 * db connection name
	 * @return
	 */
	String getName();
	
	/**
	 * db connection string
	 * @param connectionString
	 */
	void setConnectionString(String connectionString);
	
	/**
	 * open database connection
	 */
	void open();
	
	/**
	 * close database connection
	 */
	void close();
	
	/**
	 * execute query statement
	 * @param sql
	 * @return
	 */
	RecordSet select(String sql);
	
	/**
	 * execute statement, update/insert/delete
	 * @param sql
	 * @return
	 */
	int update(String sql);
	
	/**
	 * test connection state
	 * @return
	 */
	boolean isClosed();
	
	/**
	 * begin transaction
	 */
	void beginTransaction();
	
	/**
	 * commit transaction
	 */
	void commit();
	
	/**
	 * rollback transaction
	 */
	void rollback();
}
